package thread.java20221230;

public class Demo31 {
    public static void main(String[] args) throws InterruptedException {
        Object o = new Object();
        //1个线程wait
        //另一个线程, notify
        Thread t1 = new Thread(()->{
            System.out.println("wait 前");
            synchronized (o){
                try {
                    o.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("wait 后");
        });
        t1.start();

        Thread t2 = new Thread(()->{
            System.out.println("notify前");
            synchronized (o){
               o.notifyAll();
            }
            System.out.println("notify后");
        });

        t2.start();

    }
}
